<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    //数组的创建  字面量
    let arr = [1, 2, 3, '4', '哼哼']
    console.log(arr);
    //构造对象
    let arr2 = new Array('a', 'b')
    console.log(arr2);
    let arr3 = 2
    arr3[0] = 1;
    console.log(arr3);
    //数组长度
    // var heros = ["达摩", "貂蝉", "吕布"];
    // arr[arr4.legnth]='孙'
    // console.log(arr4);
    //数组判断  
    let arr5 = [1, 2]
    console.log(Array.isArray(arr5));
    //添加元素
    let arr6 = ["达摩", "貂蝉", "吕布"]
    arr6.push('刘培')
    console.log(arr6);
    console.log('-----------unshift------------');
    arr6.unshift('孙尚香')
    console.log(arr6 );
    //合并数组
    let arr7 = ['孙尚香','大乔']
    let arr8 = ['吕布','夏侯惇']
    Array.prototype.push.apply(arr7,arr8)
    console.log('----------apply--------');//改变原数组    
    console.log(arr7);
    console.log('----------concat-----------');
    console.log(arr7.concat(arr8));//不会改变原数组
    //删除组元素
    let arr9= ['a','b','c','d']
    arr9.pop(arr9)//删除数组末尾项，会改变原数组
    console.log(arr9);
    arr9.shift(arr9)
    console.log(arr9);//删除房子头
    //数组的增删改
    let arr10= ['孙尚香', '大乔', '吕布', '夏侯惇', '吕布', '夏侯惇']
    // arr10.splice(1)//一个参数代表开始一直到删完
    arr10.splice(1,2,)//一个参数开始位置（包含），第二个代表删的个数，第三个后代表要替换的值
    console.log(arr10);
        </script>